
*******************************************************************************
****						Appendix Table G7 - REGRESSION OF TOTAL TOLL ****
****			ON TIME DIFFERENTIALS: STANDARD ERROR CLUSTERING		*******
*******************************************************************************
use ".\data\clean\I10W_laneuse_dataset_15nov14_wcensus", clear

merge m:1 date hour using ".\data\clean\HV_ML_reliab.dta", keep(1 3) nogen 
gen reliabilityML=dist/p20_speedML-dist/p50_speedML
gen reliabilityHV=dist/p20_speedHV-dist/p50_speedHV
gen reliability_diff=reliabilityML-reliabilityHV

*WTP calculation
gen TT_dif_hr=dist/MLspeed-dist/ELspeed
gen WTP2=charged_toll/TT_dif_hr
drop if ELspeed==.
drop if TT_dif_hr==.
drop if holiday==1
la var TT_dif_hr "Time in Hours"
drop if dow==0|dow==6
keep if acct_type=="PRIVATE"&occupancy~="HOV-3"
keep if hour>4 & hour<9
replace reliability_diff=0 if reliability_diff<0.01
keep if reliability_diff~=.
la var reliability_diff "Reliability"
g week=week(date)

preserve
egen id=group(acct_no)
sort date hour
egen t=seq(),by(acct_no)
tsset id t
newey charged_toll TT_dif_hr reliability_diff if TT_dif_hr>0, lag(1)
newey charged_toll TT_dif_hr reliability_diff if TT_dif_hr>0, lag(2)
newey charged_toll TT_dif_hr reliability_diff if TT_dif_hr>0, lag(3)
newey charged_toll TT_dif_hr reliability_diff if TT_dif_hr>0, lag(4)
restore


est sto clear
reg charged_toll TT_dif_hr reliability_diff if TT_dif_hr>0, robust
est sto a0
reg charged_toll TT_dif_hr reliability_diff if TT_dif_hr>0,  cluster(date)
est sto a1
reg charged_toll TT_dif_hr reliability_diff if TT_dif_hr>0,  cluster(week)
est sto a2
reg charged_toll TT_dif_hr reliability_diff if TT_dif_hr>0,  cluster(month)
est sto a3
reg charged_toll TT_dif_hr reliability_diff if TT_dif_hr>0,  cluster(acct_no)
est sto a4
cgmreg charged_toll TT_dif_hr reliability_diff  if TT_dif_hr>0,  cluster(rt_id week)
est sto a5
outreg2 [a*] using temp, dec(2) ct(I; II; III; IV; V; VI) dta ///
	sortvar(Constant TT_dif_hr reliability_diff) ///
		keep( TT_dif_hr reliability_diff) e(r2 N ll aic bic)
use temp_dta, clear

esttab  a0 a1 a2 a3 a4 a5  using ".\results\appendix\tabs\ATG7.csv", replace  ///
	cells(b(star fmt(%9.2f)) se(par)) star(* 0.10 ** 0.05 *** 0.01) ///
		stats(r2 N ll aic bic,fmt(%9.2f %9.0f) ) label ///
	order(_cons TT_dif_hr reliability_diff) keep( TT_dif_hr _cons reliability_diff) ///
	mtitle(I II III IV V VI)

insheet using ".\results\appendix\tabs\ATG7.csv", comma clear
export excel using ".\results\appendix\AppendixFigsTabs.xlsx", ///
	sheet("Appendix Table G7", replace)
